//安全帽模块
const { ethers, upgrades } = require('hardhat')
// 代理合约地址
const proxyAddress = '0x5FC8d32690cc91D4c39d9d3abcBD16989F875707'

async function main() {
  console.log(proxyAddress, ' original proxy address')
  const TransparentV2 = await ethers.getContractFactory('TransparentV2')
  console.log('upgrade to TransparentV2...')
  const myTransparentV2 = await upgrades.upgradeProxy(
    proxyAddress,
    TransparentV2,
  )

  const myTransparentV2Address = myTransparentV2.target
  console.log(
    myTransparentV2Address,
    ' TransparentV2 address(should be the same)',
  )

  console.log(
    await upgrades.erc1967.getImplementationAddress(myTransparentV2Address),
    ' getImplementationAddress',
  )
  console.log(
    await upgrades.erc1967.getAdminAddress(myTransparentV2Address),
    ' getAdminAddress',
  )
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error)
    process.exit(1)
  })
